<!--
 * 菜单栏
 *
 * @Author: ShanZhu
 * @Date: 2023-12-03
-->
<template>
  <!-- 头部区域 -->
  <el-container class="home-container">
    <!-- 动态背景 -->
    <div class="conmen-bg-elements">
      <div class="conmen-floating-orb conmen-orb-1"></div>
      <div class="conmen-floating-orb conmen-orb-2"></div>
      <div class="conmen-floating-orb conmen-orb-3"></div>
    </div>

    <el-header>
      <div class="left-logo">
        <img src="../assets/logo.png"/>
        <span><h3>慧停车</h3></span>
      </div>
      <div style="text-align: right;width: 50%;padding-right: 25px">
        欢迎使用，{{ userInfo.nike }}
      </div>
      <el-button type="danger" icon="iconfont icon-back-button" @click="logout">退出登录</el-button>
    </el-header>
    <!-- 页面主体区域 -->
    <el-container class="main-container">
      <!-- 侧边栏 -->
      <el-aside width="auto">
        <el-menu
            background-color="transparent"
            text-color="rgba(255,255,255,0.7)"
            active-text-color="#00ffff"
            :unique-opened="true"
            :collapse-transition="false"
            router
            :default-active="activePath"
        >
          <!-- 菜单 -->
          <el-menu-item
              :index="item.path + ''"
              v-for="item in menuList"
              :key="item.id"
              @click="savePath('/' + item.path)"
          >
            <template slot="title">
              <i :class="item.icon"></i>
              <span><b>{{ item.name }}</b></span>
            </template>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <!-- 右侧内容主体 -->
      <el-main class="content-main">
        <!-- 路由占位符 -->
        <div class="router-view-container">
          <router-view></router-view>
        </div>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      menuList: [
        {
          name: "首页",
          id: 101,
          path: "maneHome",
          icon: "iconfont icon-home-menu",
        },
        {
          name: "用户信息管理",
          id: 111,
          path: "userMane",
          icon: "iconfont icon-user-menu",
        },
        {
          name: "车位信息管理",
          id: 131,
          path: "carmaneger",
          icon: "iconfont icon-stall-menu",
        },
        {
          name: "车位费用设置",
          id: 141,
          path: "money",
          icon: "iconfont icon-stall-fee-menu",
        },
        {
          name: "停泊车辆查询",
          id: 151,
          path: "stallMane",
          icon: "iconfont icon-paring-menu",
        },
        {
          name: "车辆进出管理",
          id: 161,
          path: "carInMane",
          icon: "iconfont icon-car-in-out-menu",
        },
        {
          name: "登录日志查询",
          id: 171,
          path: "loginInfoMane",
          icon: "iconfont icon-log-menu",
        },
        {
          name: "公告通知管理",
          id: 181,
          path: "notice",
          icon: "iconfont icon-notice-menu",
        },
        {
          name: "用户充值记录",
          id: 191,
          path: "rechargeDetail",
          icon: "iconfont icon-stall-fee-menu",
        },
      ],
      userInfo: {},
      activePath: "/users",
    };
  },
  created() {
    this.activePath = window.sessionStorage.getItem("savePath");
  },
  methods: {
    getUserInfo() {
      const uid = window.sessionStorage.getItem("token");
      axios.get("/api/user/getUserByUid?uid=" + uid).then((res) => {
        this.userInfo = res.data.data;
        window.sessionStorage.setItem("userInfo", JSON.stringify(res.data.data));
      });
    },
    logout() {
      window.sessionStorage.clear();
      this.$router.push("/login");
      this.$message("您已退出登录，请重新登录！");
    },
    savePath(savePath) {
      window.sessionStorage.setItem("savePath", savePath);
    },
  },
  mounted() {
    this.getUserInfo();
  },
};
</script>

<style scoped>
/* Mane.vue 科幻风格样式 - 与 Conmen.vue 保持一致 */
.home-container {
  height: 100vh;
  background: linear-gradient(135deg, #0c0c2e 0%, #1a1a3e 50%, #2d2d5e 100%);
  font-family: 'Arial', sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 动态背景元素 */
.conmen-bg-elements {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.conmen-floating-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.2;
  animation: conmen-float 8s ease-in-out infinite;
}

.conmen-orb-1 {
  width: 150px;
  height: 150px;
  background: linear-gradient(45deg, #00ffff, #0080ff);
  top: 15%;
  left: 5%;
  animation-delay: 0s;
}

.conmen-orb-2 {
  width: 120px;
  height: 120px;
  background: linear-gradient(45deg, #ff00ff, #8000ff);
  top: 70%;
  right: 10%;
  animation-delay: 3s;
}

.conmen-orb-3 {
  width: 80px;
  height: 80px;
  background: linear-gradient(45deg, #ffff00, #ff8000);
  bottom: 10%;
  left: 15%;
  animation-delay: 6s;
}

@keyframes conmen-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-15px) scale(1.05); }
}

/* 头部区域样式 */
.el-header {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 255, 255, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  color: #00ffff;
  font-size: 18px;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.left-logo {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 15px;
}

.left-logo > img {
  height: 40px;
  filter: drop-shadow(0 0 10px rgba(0, 255, 255, 0.5));
}

.left-logo > span h3 {
  margin: 0;
  color: #00ffff;
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
  font-weight: 300;
  letter-spacing: 1px;
}

/* 用户信息区域 */
.el-header > div:not(.left-logo) {
  color: rgba(255, 255, 255, 0.8);
  font-size: 16px;
  text-shadow: 0 0 5px rgba(0, 255, 255, 0.3);
}

/* 退出按钮样式 */
.el-button--danger {
  background: linear-gradient(135deg, #ff4757, #ff3742);
  border: none;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  padding: 10px 20px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.el-button--danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(255, 71, 87, 0.4);
  background: linear-gradient(135deg, #ff5e6d, #ff4757);
}

.el-button--danger::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.el-button--danger:hover::before {
  left: 100%;
}

/* 主容器样式 */
.main-container {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* 侧边栏样式 */
.el-aside {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border-right: 1px solid rgba(0, 255, 255, 0.1);
  box-shadow: 2px 0 20px rgba(0, 0, 0, 0.2);
  height: 100%;
  overflow-y: auto;
  flex-shrink: 0;
}

.el-menu {
  background: transparent !important;
  border-right: none !important;
}

.el-menu-item {
  background: transparent !important;
  border-left: 3px solid transparent;
  transition: all 0.3s ease;
  margin: 5px 10px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.7) !important;
}

.el-menu-item:hover {
  background: rgba(0, 255, 255, 0.1) !important;
  color: #00ffff !important;
  border-left-color: #00ffff;
  transform: translateX(5px);
}

.el-menu-item.is-active {
  background: rgba(0, 255, 255, 0.15) !important;
  color: #00ffff !important;
  border-left: 3px solid #00ffff;
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

/* 菜单图标样式 */
.iconfont {
  font-size: 20px !important;
  color: inherit !important;
  margin-right: 10px;
  transition: all 0.3s ease;
}

.el-menu-item:hover .iconfont {
  transform: scale(1.1);
}

.el-menu-item.is-active .iconfont {
  color: #00ffff !important;
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

/* 菜单文字样式 */
.el-menu-item span b {
  font-weight: 500;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
}

.el-menu-item:hover span b {
  color: #00ffff !important;
  text-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
}

.el-menu-item.is-active span b {
  color: #00ffff !important;
  text-shadow: 0 0 8px rgba(0, 255, 255, 0.7);
}

/* 主内容区域样式 */
.content-main {
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(5px);
  padding: 20px;
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  height: 100%;
}

/* 路由视图容器增强 */
.router-view-container {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 20px;
  min-height: 100%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* 滚动条样式 */
.content-main::-webkit-scrollbar {
  width: 8px;
}

.content-main::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.content-main::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #00ffff, #0080ff);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.content-main::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #00ffff, #00aaff);
}

/* 侧边栏滚动条 */
.el-aside::-webkit-scrollbar {
  width: 4px;
}

.el-aside::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 2px;
}

.el-aside::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #ff00ff, #8000ff);
  border-radius: 2px;
}

.el-aside::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #ff00ff, #aa00ff);
}

/* Firefox 滚动条支持 */
.content-main {
  scrollbar-width: thin;
  scrollbar-color: #00ffff rgba(255, 255, 255, 0.05);
}

.el-aside {
  scrollbar-width: thin;
  scrollbar-color: #ff00ff rgba(255, 255, 255, 0.05);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .el-header {
    padding: 0 10px;
    flex-direction: column;
    height: auto !important;
    padding: 10px;
  }

  .left-logo {
    margin-bottom: 10px;
  }

  .left-logo > span h3 {
    font-size: 16px;
  }

  .main-container {
    flex-direction: column;
  }

  .el-aside {
    width: 100% !important;
    height: auto;
    max-height: 200px;
  }

  .el-menu {
    display: flex;
    flex-wrap: wrap;
  }

  .el-menu-item {
    flex: 1;
    min-width: 120px;
    margin: 2px;
  }
}

@media (max-width: 480px) {
  .home-container {
    height: 100vh;
  }

  .content-main {
    padding: 10px;
  }

  .router-view-container {
    padding: 15px;
  }

  .left-logo > img {
    height: 30px;
  }

  .left-logo > span h3 {
    font-size: 14px;
  }
}

/* 动画效果 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.content-main > * {
  animation: fadeInUp 0.5s ease-out;
}

/* 确保路由内容可以正常扩展 */
.router-view {
  min-height: 100%;
}
</style>